<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>01</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <style>
        ul, li {
            list-style: none;
        }
    </style>
</head>
<body>

<div id="app">
    {{ message }}
</div>
<script>
    let app = new Vue({
        el: '#app'
        , data: {
            message: 'hello',
        }
    });
</script>

<div id="app-2">
    <span :title="message">绑定attr</span>
</div>
<script>
    let app2 = new Vue({
        el: '#app-2'
        , data: {
            message: 'title-attr'
        }
    });
</script>

<div id="app-3">
    <p v-if="is_show">
        是否显示
    </p>
</div>
<script>
    let app3 = new Vue({
        el: '#app-3'
        , data: {
            is_show: false,
        }
    })
</script>

<div id="app-4">
    <ul>
        <li v-for="data in list">
            {{ data.text }}
        </li>
    </ul>
</div>
<script>
    let app4 = new Vue({
        el: '#app-4'
        , data: {
            list: [
                {text: 'text1'}
                , {text: 'text2'}
                , {text: 'text3'}
            ]
        }
    })
</script>

<div id="app-5">
    <p> {{ message }} </p>
    <button v-on:click="clickReverse">反转文字</button>
</div>
<script>
    let app5 = new Vue({
        el: '#app-5'
        , data: {
            message: 'Hello'
        }
        , methods: {
            clickReverse: function () {
                this.message = this.message.split('').reverse().join('');
            },
        }
    })
</script>


<div id="app-6">
    <p>{{message}}</p>
    <input type="text" v-model="message">
</div>
<script>
    let app6 = new Vue({
        el: '#app-6'
        , data: {
            message: 'bind input'
        }
    });
</script>


<div id="app-7">
    <ol>
        <todo-item
                v-for="item in list"
                :todo="item"
                :key="item.id">
        </todo-item>
    </ol>
</div>
<script>
    Vue.component('todo-item', {
        prop: ['todo']
        , template: '<li>{{ todo.text }}</li>'
    })

    let app = new Vue({
        el: '#app-7',
        list: [
            {id: 0, text: 1}
            , {id: 1, text: 2}
            , {id: 2, text: 3}
            , {id: 3, text: 4}
        ]
    });
</script>

</body>
</html>